package com.personal.service.impl;

import com.personal.dao.PartnerDao;
import com.personal.domain.Partner;
import com.personal.service.PartnerService;
import com.personal.util.partDisplay.PartnerPart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @projectName: smartCommunity_springboot
 * @package: com.personal.service.impl
 * @className: PartnerServiceImpl
 * @author: bong~
 * @description: TODO
 * @date: 2023/8/10 11:18
 * @version: 1.0
 */
@Service
public class PartnerServiceImpl implements PartnerService {


    @Autowired
    private PartnerDao partnerDao;

    public List<Partner> selectAll() {
        return partnerDao.selectAll();
    }

    public List<PartnerPart> selectPartAll(){
        return partnerDao.selectPartAll();
    }

    @Override
    public List<PartnerPart> selectPartByKey(String name, String code) {
        return partnerDao.selectPartByKey(name,code);
    }

    @Override
    public boolean add(Partner partner) {
        int flag=partnerDao.add(partner);
        if(flag>0)
            return true;
        return false;
    }

    @Override
    public Partner getUpdateData(int id) {
        return partnerDao.getUpdateData(id);
    }

    @Override
    public boolean update(Partner partner) {
        int flag=partnerDao.update(partner);
        if(flag>0)
            return true;
        return false;
    }

    @Override
    public boolean delete(List<Integer> ids) {

        for(int id:ids){
            int flag=partnerDao.delete(id);
            if(flag<0)
                return false;
        }
        return true;
    }


}
